@echo off
setlocal enabledelayedexpansion
title zip-package
set userPath=.\environment

set profile=%1
set prodProfile=prod

if "%1" == "%prodProfile%" (
  set profileArg=-P %prodProfile%
) else (
  set profileArg=
)

REM package
call mvn clean package -Dmaven.test.skip=true !profileArg!

if "%profileArg%" == "" (
    rem delete WORK-RECORD
    rmdir WORK-RECORD /s /q

    rem create WORK-RECORD and conf
    mkdir WORK-RECORD
    mkdir WORK-RECORD\conf

    copy /y .\start.bat WORK-RECORD
    copy /y .\reset-environment.bat WORK-RECORD
    copy /y .\set-environment.bat WORK-RECORD
    copy /y .\README.txt WORK-RECORD
    copy /y  .\src\main\resources\application-prod.yml  WORK-RECORD\conf\application.yml
    copy /y  .\src\main\resources\data\holiday.json  WORK-RECORD\
    xcopy /y .\target\*.jar  WORK-RECORD\ /s
    xcopy /y .\environment  WORK-RECORD\environment /s /i

    %userPath%\7z\7z a WORK-RECORD\WORK-RECORD.zip WORK-RECORD
)


echo.
echo -------completed!--------
choice /t 2 /d y /n >nul